﻿<controlex:PageBase 
    x:Class="RStein.PosterousReader.WP.Views.PostDetailView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:controlex="clr-namespace:RStein.PosterousReader.WP.UI"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:mybehaviors="clr-namespace:RStein.PosterousReader.WP.Behaviors"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"     
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <controlex:ProgressBarEx  Name="prgLoadProgress" IsVisible="{Binding IsPostLoadingInProgress}" IsIndeterminate="{Binding IsPostLoadingInProgress}" AttachedContent="{Binding ElementName=tbMain}" />
        <controls:Pivot Title="{Binding AppTitle}"  Name="tbMain">
                                 
            <controls:PivotItem Header="{Binding PostTextHeader}">                
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>                    
                    <TextBlock Name="txtPostTitle" Text="{Binding SelectedPost.Title}" Style="{StaticResource PhoneTextLargeStyle}" Grid.Row="0" TextWrapping="Wrap"></TextBlock>
                    <ScrollViewer Grid.Row="1">
                        <phone:WebBrowser Name="wbPostBody" mybehaviors:WebBrowserNavigateBehavior.NavigateText="{Binding SelectedPost.Body, Mode=OneWay}">                                                   
                        </phone:WebBrowser>
                    </ScrollViewer>
                </Grid>
                
            </controls:PivotItem>
 
            <!--Pivot item two-->
            <controls:PivotItem Header="{Binding PostCommentsHeader}"> 
                <!--Triple line list no text wrapping-->
                <toolkit:LongListSelector x:Name="lstcomments" Margin="0,0,-12,0" ItemsSource="{Binding SelectedPost.Comments}" IsFlatList="True">
                        <toolkit:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                     <TextBlock Text="{Binding Author}" TextWrapping="NoWrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                    <TextBlock Text="{Binding Text}" TextWrapping="Wrap" Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                </StackPanel>
                            </DataTemplate>
                    </toolkit:LongListSelector.ItemTemplate>
                </toolkit:LongListSelector>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">            
            <shell:ApplicationBarIconButton IconUri="/Icons/appbar.edit.rest.png" Text="Upravit" Click="Edit_Click"/>
         </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</controlex:PageBase>